<?php

/**
 * Created by PhpStorm.
 * User: hhh
 * Date: 2016/11/8
 * Time: 11:35
 */
class Review extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('review_m','review');
        $this->load->library('result');
    }

    function getReviewsByProductId(){
        $id=$this->uri->segment(3,0);
        $start=$this->uri->segment(4,0);
        $limit=$this->uri->segment(5,20);

        $results=$this->review->getReviewsByProductId($id,$start,$limit);

        if(isset($results)){
            $this->result->setData(0,"数据获取成功",$results);
        }else{
            $this->result->setData(1,"数据获取失败",null);
        }
        $this->result->output();
    }

    function getTotalReviewsByProductId(){
        $id=$this->uri->segment(3,0);
        $results=$this->review->getTotalReviewsByProductId($id);

        if(isset($results)){
            $this->result->setData(0,"数据获取成功",$results);
        }else{
            $this->result->setData(1,"数据获取失败",null);
        }
        $this->result->output();
    }
}